package com.briup.app04.dao;

import com.briup.app04.bean.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;
public interface ArticleMapper {
    @Results(
            {       @Result(column="publish_data",property="publishDate"),
                    @Result(column="read_times",property="readTimes"),
                    @Result(column="thump_up_times",property="thumbUpTimes"),
                    @Result(column="thumb_down_times",property="thumbDownTimes"),
                    @Result(column="category_id",property="categoryId"),
                    @Result(column="user_id",property="userId")
            }
    )

    @Select("select * from cms_article")
    List<Article>selectAll();
    @Insert("insert into cms_article values(null,#{title},#{content},#{publishDate},#{readTimes},#{thumbUpTimes},#{thumbDownTimes},#{status},#{categoryId},#{userId})")
    void insert(Article article);
    @Update("update cms_article set title=#{title},content=#{content},publish_date=#{publishDate},read_times=#{readTimes},thumb_up_times=#{thumbUpTimes},thumb_down_times=#{thumbDownTimes},status=#{status},category_id=#{categoryId},user_id=#{userId} where id=#{id}")
    void update(Article article);
    @Delete("delete from cms_article where id=#{id}")
    void deleteById(Long id);


}
